package com.unicom.mec.base.controller;


import com.unicom.mec.base.common.ResultBean;
import com.unicom.mec.base.service.DictService;
import com.unicom.mec.base.vo.DictVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 数据字典控制层
 *
 * @author 刘亮武
 * @date 2020年06月15日
 */
@Api(value = "/dict", tags = "数据字典管理")
@RestController
@RequestMapping("/dict")
public class DictController {

    @Autowired
    private DictService dictService;

    @ApiOperation(value = "查询字典项", httpMethod = "GET")
    @GetMapping("/")
    @ResponseBody
    ResultBean<List<DictVo>> findDict(@ApiParam(value = "字典KEY") @RequestParam(value = "dictKey") String dictKey,
                                      @ApiParam(value = "字典值集合") @RequestParam(value = "values", required = false) List<String> values) {
        List<DictVo> dictVos = dictService.findDict(dictKey,values);
        ResultBean<List<DictVo>> result = new ResultBean<>();
        result.setData(dictVos);
        return result;
    }
}
